package com.iss.airsys.dao;

import com.iss.airsys.entity.User;
import com.iss.airsys.entity.Userinfo;
import com.iss.airsys.model.UserWithRole;
import com.iss.airsys.service.UserService;
import org.apache.ibatis.annotations.*;
import org.hibernate.query.criteria.internal.expression.function.AggregationFunction;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

@Repository
@Mapper
public interface UserDao {
    //登陆
    @Select("select u_name,r_id,r_name from user inner join userRole on r_id=u_roleid where u_name=#{u_name} and u_pwd=#{u_pwd}")
    UserWithRole selectUser(User user);
    //检查注册用户名是否存在
    @Select("select * from user where u_name=#{u_name} ")
    User CheckUserName(String u_name);
    //注册用户
    @Insert("insert into user values(#{u_id},#{u_name},#{u_pwd},#{u_roleid})")
    int addUser (User user);
    //针对忘记密码的update
    @Update("update user set u_pwd=#{u_pwd} where u_name=#{u_name}")
    int updateUser(@Param("u_name") String uInfo_name, @Param("u_pwd")String uInfo_pwd);
    @Select("select uInfo_name from userinfo where uInfo_phone=#{uInfo_phone}")
    String selectuserInfoByphone(String uInfo_phone);
}
